package cn.szzsi._admin;

import cn.szzsi.common.kit.CommonUtil;
import cn.szzsi.common.model.Shipping;
import com.jfinal.kit.StrKit;

import java.util.List;

/**
 * 商户后台类 - 发货
 * Created by yuanzheg on 2016/10/13.
 */
public class ShippingController extends BaseAdminController<Shipping> {
    private String shopId;
    // 列表
    public void list() {
        render("shipping_manage_list.html");
    }
    //ajax list
    public void ajaxlist(){
        shopId=getAttr("shopId");
        List<Shipping> ls = Shipping.dao.find("select s.*,m.code from mall_shipping s LEFT JOIN mall_orders o on s.order_id=o.id LEFT JOIN mall_member m on o.member_id=m.id where s.uid = ?  order by s.createDate desc",shopId);
        renderJson(ls);
    }

    // 查看
    public void view(){
        id = getPara("id","");
        if(StrKit.notBlank(id)){
            setAttr("shipping", Shipping.dao.findById(id));
        }
        render("shipping_manage_view.html");
    }

    // 删除
    public void delete(){
        ids = getParaValues("ids");
        if(ids != null && ids.length > 0){
            for(String id : ids){
                if(Shipping.dao.deleteById(id)){
                    ajaxJsonSuccessMessage("删除成功！");
                }else{
                    ajaxJsonErrorMessage("删除失败！");
                }
            }
        }
    }
}
